package com.ruoyi.core.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.entity.CoreEntity.PointRecords;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;

import com.ruoyi.core.service.IPointRecordsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 积分变动明细Controller
 * 
 * @author ruoyi
 * @date 2025-08-07
 */
@RestController
@RequestMapping("/pointRecords")
public class PointRecordsController extends BaseController
{
    @Autowired
    private IPointRecordsService pointRecordsService;

    /**
     * 查询积分变动明细列表
     */
    @RequiresPermissions("core:pointRecords:list")
    @GetMapping("/list")
    public TableDataInfo list(PointRecords pointRecords)
    {
        startPage();
        List<PointRecords> list = pointRecordsService.selectPointRecordsList(pointRecords);
        return getDataTable(list);
    }

    /**
     * 导出积分变动明细列表
     */
    @RequiresPermissions("core:pointRecords:export")
    @Log(title = "积分变动明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PointRecords pointRecords)
    {
        List<PointRecords> list = pointRecordsService.selectPointRecordsList(pointRecords);
        ExcelUtil<PointRecords> util = new ExcelUtil<PointRecords>(PointRecords.class);
        util.exportExcel(response, list, "积分变动明细数据");
    }

    /**
     * 获取积分变动明细详细信息
     */
    @RequiresPermissions("core:pointRecords:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pointRecordsService.selectPointRecordsById(id));
    }

    /**
     * 新增积分变动明细
     */
    @RequiresPermissions("core:pointRecords:add")
    @Log(title = "积分变动明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PointRecords pointRecords)
    {
        return toAjax(pointRecordsService.insertPointRecords(pointRecords));
    }

    /**
     * 修改积分变动明细
     */
    @RequiresPermissions("core:pointRecords:edit")
    @Log(title = "积分变动明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PointRecords pointRecords)
    {
        return toAjax(pointRecordsService.updatePointRecords(pointRecords));
    }

    /**
     * 删除积分变动明细
     */
    @RequiresPermissions("core:pointRecords:remove")
    @Log(title = "积分变动明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pointRecordsService.deletePointRecordsByIds(ids));
    }
}
